import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '../layout/Layout'

/**
* hidden: true                   if `hidden:true` will not show in the sidebar(default is false)
* alwaysShow: true               if set true, will always show the root menu, whatever its child routes length
*                                if not set alwaysShow, only more than one route under the children
*                                it will becomes nested mode, otherwise not show the root menu
* redirect: noredirect           if `redirect:noredirect` will no redirect in the breadcrumb
* name:'router-name'             the name is used by <keep-alive> (must set!!!)
* meta : {
    title: 'title'               the name show in submenu and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar,
  }
**/

export const constantRouterMap = [
  { path: '/login',
    meta: { title: '登录', noCache: true },
    component: () => import('@/views/login'),
    hidden: true
  },
  { path: '/register',
    meta: { title: '注册', noCache: true },
    component: () => import('@/views/register'),
    hidden: true
  },
  { path: '/password_find',
    meta: { title: '找回密码', noCache: true },
    component: () => import('@/views/password_find'),
    hidden: true
  },
  {
    path: '/404',
    component: () => import('@/views/features/404'),
    hidden: true
  },
  {
    path: '/401',
    component: () => import('@/views/features/401'),
    hidden: true
  },
  {
    path: '/redirect',
    component: Layout,
    hidden: true,
    children: [
      {
        path: '/redirect/:path*',
        component: () => import('@/views/features/redirect')
      }
    ]
  },
  {
    path: '/',
    component: Layout,
    redirect: '/chaomall/home',
    meta: { title: '首页', icon: 'index' }
  },
  {
    path: '/user',
    component: Layout,
    hidden: true,
    redirect: 'noredirect',
    children: [
      {
        path: 'center',
        component: () => import('@/views/chaomall/system/user/center'),
        name: '个人中心',
        meta: { title: '个人中心', icon: 'user' }
      }
    ]
  },
  {
    path: '/customer',
    component: Layout,
    hidden: true,
    redirect: 'noredirect',
    children: [
      {
        path: 'viewDetails',
        component: () => import('@/views/chaomall/customer/promoterlist/viewDetails'),
        name: '查看客户详情',
        meta: { title: '查看客户详情', icon: 'index' }
      },
      {
        path: 'viewCustomer',
        component: () => import('@/views/chaomall/customer/promoterlist/index'),
        name: '查看客户列表',
        meta: { title: '客户列表', icon: 'index' }
      }
    ]
  },
  {
    path: '/commodity',
    component: Layout,
    hidden: true,
    redirect: 'noredirect',
    children: [
      {
        path: 'details',
        component: () => import('@/views/chaomall/commodity/publish/setDetails'),
        name: '宝贝详情',
        meta: { title: '宝贝详情', icon: 'index' }
      },
      {
        path: 'addCard',
        component: () => import('@/views/chaomall/commodity/addCard/index'),
        name: '发布产品',
        meta: { title: '发布产品', icon: 'index' }
      },
      {
        path: 'cardList',
        component: () => import('@/views/chaomall/commodity/cardList/index'),
        name: '产品列表',
        meta: { title: '产品列表', icon: 'index' }
      },
      {
        path: 'classify',
        component: () => import('@/views/chaomall/commodity/publish/index'),
        name: '选择宝贝分类',
        meta: { title: '选择宝贝分类', icon: 'index' }
      },
      {
        path: 'success',
        component: () => import('@/views/chaomall/commodity/publish/success'),
        name: '宝贝发布',
        meta: { title: '宝贝发布', icon: 'index' }
      },
      {
        path: 'cardSuccess',
        component: () => import('@/views/chaomall/commodity/addCard/success'),
        name: '宝贝发布',
        meta: { title: '宝贝发布', icon: 'index' }
      },
      {
        path: 'list',
        component: () => import('@/views/chaomall/commodity/list/index'),
        name: '宝贝列表',
        meta: { title: '宝贝列表', icon: 'index' }
      },
      {
        path: 'pointsmall',
        component: () => import('@/views/chaomall/commodity/pointsmall/commodity'),
        name: '积分产品',
        meta: { title: '积分产品', icon: 'index' }
      },
      {
        path: 'pointsmalllist',
        component: () => import('@/views/chaomall/commodity/pointsmall/index'),
        name: '积分产品',
        meta: { title: '积分产品列表', icon: 'index' }
      }
      // /shop/commodity-type
    ]
  },
  // 宝贝分类新窗口打开
  {
    path: '/commodity-type',
    component: () => import('@/views/chaomall/shop/commodityType'),
    meta: { title: '宝贝分类', noCache: true },
    hidden: true
  },
  // 发布宝贝新建运费打开新窗口
  {
    path: '/freight-list',
    component: () => import('@/views/chaomall/shop/config'),
    meta: { title: '运费模版', noCache: true },
    hidden: true
  },
  {
    path: '/commodity-list',
    component: () => import('@/views/chaomall/commodity/list/index'),
    meta: { title: '宝贝列表', noCache: true },
    hidden: true
  },
  {
    path: '/hotBank',
    component: Layout,
    hidden: true,
    redirect: 'noredirect',
    children: [
      {
        path: 'bankDetail',
        component: () => import('@/views/chaomall/hotbank/addBank'),
        name: '热门银行设置',
        meta: { title: '银行设置', noCache: true }
      }
    ]
  },
  {
    path: '/team',
    component: Layout,
    hidden: true,
    redirect: 'noredirect',
    children: [
      {
        path: 'teamDetail',
        component: () => import('@/views/chaomall/team/addTeam'),
        name: '团队新增',
        meta: { title: '团队新增', noCache: true }
      }
    ]
  },
  {
    path: '/order',
    component: Layout,
    hidden: true,
    redirect: 'noredirect',
    children: [
      {
        path: 'cardOrder',
        component: () => import('@/views/chaoerp/order/bankcardorder/detail'),
        name: '查看信用卡订单详情',
        meta: { title: '查看订单详情', icon: 'index' }
      },
      {
        path: 'pointsOrder',
        component: () => import('@/views/chaoerp/order/pointsOrder/detail'),
        name: '查看信用卡订单详情',
        meta: { title: '查看订单详情', icon: 'index' }
      }
    ]
  },
  {
    path: '/strategy',
    component: Layout,
    hidden: true,
    redirect: 'noredirect',
    children: [
      {
        path: 'addStrategy',
        component: () => import('@/views/chaomall/system/strategy/addStrategy'),
        name: '攻略新增',
        meta: { title: '攻略新增', noCache: true }
      }
    ]
  },
  {
    path: '/shop',
    component: Layout,
    hidden: true,
    redirect: 'noredirect',
    children: [
      {
        path: 'addFreight',
        component: () => import('@/views/chaomall/shop/config/addFreight'),
        name: '新增运费模版',
        meta: { title: '新增运费模版', icon: 'index' }
      },
      {
        path: 'toIndex',
        component: () => import('@/views/chaomall/shop/config'),
        name: '商城设置',
        meta: { title: '商城设置', icon: 'index' }
      }
    ]
  }
  // { path: '*', redirect: '/404', hidden: true }
]

export default new Router({
  mode: 'history',
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRouterMap
})
